//
//  SCAWishViewModel.m
//  Mutal
//
//  Created by TonyStart on 16/10/22.
//  Copyright © 2016年 com.wx. All rights reserved.
//

#import "SCAWishViewModel.h"

/*
 wish_title     愿望标题   必须
 wish_desc     愿望内容   必须
 wish_price     愿望金额   必须
 city       城市     必须（字符串）
 province 省份   必须（字符串）
 user_id       发布人id   必须
 wish_type     愿望类型   （1.普通,2.预热）
 wish_end_time  愿望结束时间 格式：（2016-05-02）
 mobile 愿望发布手机号码
 最多发布三张图片，对应键值为pic1, pic2, pic3
 */
@implementation SCAWishViewModel
-(void)saveAWish:(SCAWishModel*)wish type:(NSInteger)type finish:(void(^)(BOOL isSucess))finish{
    
    NSMutableString *url = [NSMutableString stringWithString:@"http://www.scxxhs.com/huzhu/index.php?g=Appapi&m=wish&a=addwish&"];
    [url appendString:[NSString stringWithFormat:@"wish_title=%@&",wish.wish_title]];
    [url appendString:[NSString stringWithFormat:@"wish_desc=%@&",wish.wish_desc]];
    [url appendString:[NSString stringWithFormat:@"wish_price=%@&",wish.wish_price]];
    [url appendString:[NSString stringWithFormat:@"city=%@&",wish.city]];
    [url appendString:[NSString stringWithFormat:@"province=%@&",wish.province]];
    [url appendString:[NSString stringWithFormat:@"user_id=%@&",wish.user_id]];
    [url appendString:[NSString stringWithFormat:@"wish_type=%ld&",type]];
    [url appendString:[NSString stringWithFormat:@"wish_end_time=%@&",wish.wish_end_time]];
    [url appendString:[NSString stringWithFormat:@"mobile=%@",wish.mobile]];
    
    for (int i=0; i<wish.pics.count; i++) {
        [url appendString:[NSString stringWithFormat:@"&pic%d=%@",i,wish.pics[i]]];
    }
    
    [[SCNetworkTool shared] requestDataWithMethod:POST url:url finish:^(id data, NSError *err,NSInteger code) {
        NSLog(@"%@",data);
    }];
}
@end
